home *** CD-ROM | disk | FTP | other *** search
/ Programming Microsoft Visual Basic .NET / Programming Microsoft Visual Basic .NET (Microsoft Press)(X08-78517)(2002).bin / setup / vbnet / 09 array, lists, and collections / listboxreverse / form1.vb < prev    next >
Encoding:
Text File  |  2001-07-27  |  2.8 KB  |  80 lines

  1. Public Class Form1
  2.     Inherits System.Windows.Forms.Form
  3.  
  4. #Region " Windows Form Designer generated code "
  5.  
  6.     Public Sub New()
  7.         MyBase.New()
  8.  
  9.         'This call is required by the Windows Form Designer.
  10.         InitializeComponent()
  11.  
  12.         'Add any initialization after the InitializeComponent() call
  13.  
  14.     End Sub
  15.  
  16.     'Form overrides dispose to clean up the component list.
  17.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  18.         If disposing Then
  19.             If Not (components Is Nothing) Then
  20.                 components.Dispose()
  21.             End If
  22.         End If
  23.         MyBase.Dispose(disposing)
  24.     End Sub
  25.     Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
  26.     Friend WithEvents Button1 As System.Windows.Forms.Button
  27.  
  28.     'Required by the Windows Form Designer
  29.     Private components As System.ComponentModel.Container
  30.  
  31.     'NOTE: The following procedure is required by the Windows Form Designer
  32.     'It can be modified using the Windows Form Designer.  
  33.     'Do not modify it using the code editor.
  34.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  35.         Me.ListBox1 = New System.Windows.Forms.ListBox()
  36.         Me.Button1 = New System.Windows.Forms.Button()
  37.         Me.SuspendLayout()
  38.         '
  39.         'ListBox1
  40.         '
  41.         Me.ListBox1.ItemHeight = 20
  42.         Me.ListBox1.Items.AddRange(New Object() {"First", "Second", "Third", "Fourth", "Fifth" & ChrW(9)})
  43.         Me.ListBox1.Location = New System.Drawing.Point(8, 16)
  44.         Me.ListBox1.Name = "ListBox1"
  45.         Me.ListBox1.Size = New System.Drawing.Size(240, 184)
  46.         Me.ListBox1.TabIndex = 0
  47.         '
  48.         'Button1
  49.         '
  50.         Me.Button1.Location = New System.Drawing.Point(288, 16)
  51.         Me.Button1.Name = "Button1"
  52.         Me.Button1.Size = New System.Drawing.Size(120, 48)
  53.         Me.Button1.TabIndex = 1
  54.         Me.Button1.Text = "Reverse"
  55.         '
  56.         'Form1
  57.         '
  58.         Me.AutoScaleBaseSize = New System.Drawing.Size(8, 19)
  59.         Me.ClientSize = New System.Drawing.Size(432, 221)
  60.         Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.ListBox1})
  61.         Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 12!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  62.         Me.Name = "Form1"
  63.         Me.Text = "Form1"
  64.         Me.ResumeLayout(False)
  65.  
  66.     End Sub
  67.  
  68. #End Region
  69.  
  70.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  71.         ' create a wrapper around the Listbox.Items IList collection.
  72.         'Dim lbAdapter As ArrayList = ArrayList.Adapter(ListBox1.Items)
  73.         ' reverse their order
  74.         'lbAdapter.Reverse()
  75.  
  76.         ArrayList.Adapter(ListBox1.Items).Reverse()
  77.  
  78.     End Sub
  79. End Class
  80.